/*
 * JSF Toolkit Component Framework
 * Copyright (C) 2007 Noah Sloan <iamnoah A-T gmail D0T com>
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 */
package com.jsftoolkit.base.components;

import com.jsftoolkit.base.RequiresResources;
import com.jsftoolkit.base.ResourceConstants;
import com.jsftoolkit.gen.builder.ComponentBuilder;
import com.jsftoolkit.gen.info.PropertyInfo;
import com.jsftoolkit.utils.Utils;

public class IncludeResourceSpec extends ComponentBuilder {

	public static final PropertyInfo RESOURCE = new PropertyInfo(String.class,
			"resource", null, true);

	public static final PropertyInfo TYPE = new PropertyInfo(String.class,
			"type","Utils.getValue(getResource(),\"\").endsWith(\".css\") ? \"style\" : \"script\"");

	public static final PropertyInfo ENCODING = new PropertyInfo(String.class,
			"encoding", "\"UTF-8\"");

	public static final PropertyInfo FILTER = new PropertyInfo(boolean.class,
			"filter", "\"style\".equalsIgnoreCase(getType())");

	public static final PropertyInfo FILTER_BEAN = new PropertyInfo(
			String.class, "filterBean", ResourceConstants.class.getSimpleName()
					+ ".SKINNING_FILTER");
	{
		assert ResourceConstants.SKINNING_FILTER != null;
	}

	{
		abstractClass().named("IncludeResource").in(
				"com.jsftoolkit.base.components");
		ofType("com.jsftoolkit.IncludeResource").inFamily(
				"com.jsftoolkit.IncludeResource");

		requiring(ResourceConstants.class,Utils.class);

		andProperties(RESOURCE, TYPE, FILTER_BEAN, FILTER, ENCODING);

		implementing(RequiresResources.class);

		withConfig().registeringRenderer(""); 
	}

}
